package NetAPI;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDPClient {
    public static void receiver() throws IOException {
        DatagramSocket socket = new DatagramSocket(9090);
        byte[] buffer = new byte[100];
        DatagramPacket packet = new DatagramPacket(buffer, 0,
                buffer.length);
        socket.receive(packet);
        System.out.println(new String(packet.getData(), 0, packet.getLength()));
        socket.close();
    }

    public static void main(String[] args) {
        while (true) {
            try {
                Thread.sleep(300);
                receiver();
            } catch (InterruptedException | IOException e) {
                e.printStackTrace();
            }
        }
    }
}
